package com.isunland.managesystem.adapter;

import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import butterknife.BindView;
import com.isunland.managesystem.R;
import com.isunland.managesystem.base.BaseButterKnifeAdapter;
import com.isunland.managesystem.base.BaseVolleyActivity;
import com.isunland.managesystem.entity.RProInvoiceRecd;
import com.isunland.managesystem.utils.MyStringUtil;
import com.isunland.managesystem.utils.MyUtils;
import com.isunland.managesystem.widget.CustomTextView;
import java.util.ArrayList;

public class ReceiptAdapter extends BaseButterKnifeAdapter<RProInvoiceRecd> {

  public ReceiptAdapter(BaseVolleyActivity context, ArrayList<RProInvoiceRecd> objects) {
    super(context, objects);
    // Auto-generated constructor stub
  }

  @Override protected int setLayoutId() {
    return R.layout.adapter_receipt;
  }

  protected class ViewHolder extends BaseViewHolder {
    @BindView(R.id.iv_logo) CustomTextView ivLogo;
    @BindView(R.id.tv_certificate_name) TextView tvCertificateName;
    @BindView(R.id.tv_planStatus) TextView tvPlanStatus;
    @BindView(R.id.tv_expense_desc) TextView tvExpenseDesc;
    @BindView(R.id.tv_loanMoney) TextView tvLoanMoney;

    ViewHolder(View view) {
      super(view);
    }
  }

  @NonNull @Override protected BaseViewHolder initHolder(View convertView) {
    return new ViewHolder(convertView);
  }

  @Override protected void initView(RProInvoiceRecd item, BaseViewHolder baseHolder, int position) {
    ViewHolder vh = (ViewHolder) baseHolder;
    vh.ivLogo.setText(MyStringUtil.substring(item.getContractBillName(), 0, 2));
    vh.tvCertificateName.setText(item.getContractBillName());
    vh.tvExpenseDesc.setText(item.getContent());
    vh.tvLoanMoney.setText(item.getContractAmount() + "元");
    MyUtils.switchDataStutus(context, vh.tvPlanStatus, item.getDataStatus());
  }
}
